package com.java110.mall.shop.smo.impl;


import com.java110.intf.shop.IShopTypeInnerServiceSMO;
import com.java110.po.shop.ShopTypePo;
import com.java110.mall.shop.dao.IShopTypeServiceDao;
import com.java110.dto.shop.ShopTypeDto;
import com.java110.utils.util.BeanConvertUtil;
import com.java110.core.base.smo.BaseServiceSMO;
import com.java110.dto.PageDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @ClassName FloorInnerServiceSMOImpl
 * @Description 店铺类型管理内部服务实现类
 * @Author wuxw
 * @Date 2019/4/24 9:20
 * @Version 1.0
 * add by wuxw 2019/4/24
 **/
@RestController
public class ShopTypeInnerServiceSMOImpl extends BaseServiceSMO implements IShopTypeInnerServiceSMO {

    @Autowired
    private IShopTypeServiceDao shopTypeServiceDaoImpl;


    @Override
    public int saveShopType(@RequestBody ShopTypePo shopTypePo) {
        int saveFlag = 1;
        shopTypeServiceDaoImpl.saveShopTypeInfo(BeanConvertUtil.beanCovertMap(shopTypePo));
        return saveFlag;
    }

     @Override
    public int updateShopType(@RequestBody  ShopTypePo shopTypePo) {
        int saveFlag = 1;
         shopTypeServiceDaoImpl.updateShopTypeInfo(BeanConvertUtil.beanCovertMap(shopTypePo));
        return saveFlag;
    }

     @Override
    public int deleteShopType(@RequestBody  ShopTypePo shopTypePo) {
        int saveFlag = 1;
        shopTypePo.setStatusCd("1");
        shopTypeServiceDaoImpl.updateShopTypeInfo(BeanConvertUtil.beanCovertMap(shopTypePo));
        return saveFlag;
    }

    @Override
    public List<ShopTypeDto> queryShopTypes(@RequestBody  ShopTypeDto shopTypeDto) {

        //校验是否传了 分页信息

        int page = shopTypeDto.getPage();

        if (page != PageDto.DEFAULT_PAGE) {
            shopTypeDto.setPage((page - 1) * shopTypeDto.getRow());
        }

        List<ShopTypeDto> shopTypes = BeanConvertUtil.covertBeanList(shopTypeServiceDaoImpl.getShopTypeInfo(BeanConvertUtil.beanCovertMap(shopTypeDto)), ShopTypeDto.class);

        return shopTypes;
    }


    @Override
    public int queryShopTypesCount(@RequestBody ShopTypeDto shopTypeDto) {
        return shopTypeServiceDaoImpl.queryShopTypesCount(BeanConvertUtil.beanCovertMap(shopTypeDto));    }

    public IShopTypeServiceDao getShopTypeServiceDaoImpl() {
        return shopTypeServiceDaoImpl;
    }

    public void setShopTypeServiceDaoImpl(IShopTypeServiceDao shopTypeServiceDaoImpl) {
        this.shopTypeServiceDaoImpl = shopTypeServiceDaoImpl;
    }
}
